/*
 * MessageResource.h
 *
 *  Created on: 2013. 9. 10.
 *      Author: mega@gamevil.com
 */

#ifndef MESSAGERESOURCE_H_
#define MESSAGERESOURCE_H_

#include <map>
#include <Toolkit/Str.h>

namespace ProjectZ { namespace NResource {

class MessageData
{
public:
	// 메시지 리스트와 공유
	enum message_type {
		// Kakao Message
		invite_no_game_user	= 0,
		_kakao_message_max,

		// Push Message
		request_connect = 100,
		send_heart,
		friend_buff,
		boast,
		_push_message_max,
	};

public:
	struct Flyweight
	{
		int _ACTION_TYPE;

		Toolkit::Str<100> _MSG0_TITLE;
		Toolkit::Str<400> _MSG0;
		Toolkit::Str<100> _MSG1_TITLE;
		Toolkit::Str<400> _MSG1;
		Toolkit::Str<100> _MSG2_TITLE;
		Toolkit::Str<400> _MSG2;
		Toolkit::Str<100> _MSG3_TITLE;
		Toolkit::Str<400> _MSG3;

		time_t _S_TIME1;
		time_t _E_TIME1;
		time_t _S_TIME2;
		time_t _E_TIME2;
		time_t _S_TIME3;
		time_t _E_TIME3;
	};

public:
	MessageData() {}
	virtual ~MessageData();

	bool LoadResource(int company, int saleCode);
	typedef std::map<int, Flyweight *>	DATATREE;
	DATATREE & GetTree();
	Flyweight * FindFly(int actionType);

	bool	IsKakaoMessage(int actionType);
	int		GetKakaoMessageCount();

private:
	void	Clear();

private:
	DATATREE	clsFlyTree;
};


class MessageResource
{
public:
	MessageResource();
	virtual ~MessageResource();

	bool LoadResource();
	MessageData * GetMessageData(User * pUser);
	MessageData::Flyweight * GetFly(int company, int salecode, int actionType);

	bool	SetMessageFromType(int company, int salecode, MessageData::message_type eType, std::string & sender, std::string & message);

private:
	MessageData * pMsgAD;
	MessageData * pMsgIOS;
};

} /* NResource */ } /* ProjectZ */

#endif /* MESSAGERESOURCE_H_ */
